import 'package:flutter/material.dart';

///访客登记页面卡片布局
class CardPositionView extends StatelessWidget {
  final String? assetPath;
  final double imageWidth;
  final double imageHeight;
  final String? text;
  final double? left;
  final double? right;
  final double? top;
  final double? bottom;
  final VoidCallback? onTap;
  final Color? imageColor;
  final Widget icon;
  final Color textColor;
  final double fontSize;
  final EdgeInsets? textMargin;

  CardPositionView(
      {Key? key,
      this.assetPath,
      this.imageWidth = 60,
      this.imageHeight = 60,
      @required this.text,
      this.textColor = Colors.green,
      this.fontSize = 20,
      this.textMargin,
      this.left,
      this.right,
      this.top,
      this.bottom,
      this.onTap,
      this.imageColor,
      this.icon = const Icon(
        Icons.toys,
        size: 50,
        color: Colors.white,
      )})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Positioned(
      child: Card(
        borderOnForeground: false,
        color: Colors.white.withAlpha(10),
        child: InkWell(
          splashColor: Colors.yellow.withAlpha(30),
          onTap: this.onTap,
          child: Container(
            alignment: Alignment.center,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: [
                this.assetPath == null
                    ? this.icon
                    : Image.asset(
                        this.assetPath!,
                        height: this.imageHeight, //80
                        width: this.imageWidth, //80
                        fit: BoxFit.cover,
                        color: this.imageColor,
                      ),
                Container(
                  margin: this.textMargin,
                  child: Text(
                    this.text!,
                    style: TextStyle(
                      color: this.textColor,
                      fontWeight: FontWeight.bold,
                      fontSize: this.fontSize,
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),

      height: 200,
      //200
      width: 400,
      //400
      left: this.left,
      top: this.top,
      bottom: this.bottom,
      right: this.right,
    );
  }
}
